<html>
<head><meta charset="utf-8"><title>moving toward an RFC · project-ffi-unwind · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/index.html">project-ffi-unwind</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/moving.20toward.20an.20RFC.html">moving toward an RFC</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="191949813"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/moving%20toward%20an%20RFC/near/191949813" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/moving.20toward.20an.20RFC.html#191949813">(Mar 26 2020 at 21:13)</a>:</h4>
<p>OK, so, we discussed this in today's lang team meeting. It seems like most folks at this juncture favor the "extern <code>C unwind</code>" alternative -- there are some <a href="https://github.com/rust-lang/lang-team/blob/master/minutes/2020-03-26.md#shepherded-item-updates" title="https://github.com/rust-lang/lang-team/blob/master/minutes/2020-03-26.md#shepherded-item-updates">summaries in the ffi-unwind section here</a>.</p>



<a name="191950165"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/moving%20toward%20an%20RFC/near/191950165" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/moving.20toward.20an.20RFC.html#191950165">(Mar 26 2020 at 21:15)</a>:</h4>
<p>We were saying that it seems like at this point it would make sense to make a revised RFC that states</p>
<ul>
<li>add "C unwind"</li>
<li>
<p>clarifies that all unwinding across a C ABI is UB <strong>except</strong> the case of:<br>
    * forced unwind where no destructors are on stack</p>
</li>
<li>
<p>requires an abort guard in the case of a <code>extern "C" fn foo()</code> compiled with panic=unwind (to avoid UB)</p>
</li>
<li>declares that unwinding across a "C unwind" ABI is currently<br>
    * permitted for exceptions that arose from a Rust panic<br>
    * "not yet specified" for foreign exceptions (that will be follow-up work)</li>
</ul>



<a name="191950169"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/moving%20toward%20an%20RFC/near/191950169" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/moving.20toward.20an.20RFC.html#191950169">(Mar 26 2020 at 21:15)</a>:</h4>
<p>I think that covers it</p>



<a name="191950775"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/moving%20toward%20an%20RFC/near/191950775" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/moving.20toward.20an.20RFC.html#191950775">(Mar 26 2020 at 21:21)</a>:</h4>
<p>I have one hesitation, but I don't think it has to block the RFC. In particular, I've been pondering the case of foreign exceptions propagating across Rust frames. I think that ideally we'd be able to support this, but if we did decide <em>not</em> to -- to make it UB, essentially -- then that might push me to support the "one ABI" option. After all, in that case, there is no "new UB" involved in switching from panic=unwind to panic=abort -- foreign exceptions are UB no matter what. Basically this would (iiuc) just mean that we no longer annotate foreign functions as 'nounwind' unless we have panic=abort (because Rust panics might propagate).</p>
<p>(It <em>would</em> though still imply that changing the Rust unwinding mechanism to be distinct from the system mechanism is more costly; I don't personally think we should change the Rust unwinding mechanism anyway, so that doesn't bother me so much.)</p>
<p>However, it's also true that in that case we could just deprecate "C unwind" and make it synonymous with "C", so I don't really care.  And ultimately I do think it's important for us to enable smoother C++ interop, and I think permitting exceptions might be an important part of that. </p>
<p>(All of that said I might like to include some bit of these trade-offs in the RFC)</p>



<a name="191993526"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/moving%20toward%20an%20RFC/near/191993526" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/moving.20toward.20an.20RFC.html#191993526">(Mar 27 2020 at 09:38)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116009">nikomatsakis</span> <a href="#narrow/stream/210922-project-ffi-unwind/topic/moving.20toward.20an.20RFC/near/191950165" title="#narrow/stream/210922-project-ffi-unwind/topic/moving.20toward.20an.20RFC/near/191950165">said</a>:</p>
<blockquote>
<ul>
<li>requires an abort guard in the case of a <code>extern "C" fn foo()</code> compiled with panic=unwind (to avoid UB)</li>
</ul>
</blockquote>
<p>libstd is always compiled with panic=unwind, so a foreign unwind will always find a landing pad when the current thread is either the main thread for <code>--crate-type bin</code>, or the current thread is spawned using <code>std::thread::spawn</code>.</p>



<a name="191996280"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/moving%20toward%20an%20RFC/near/191996280" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/moving.20toward.20an.20RFC.html#191996280">(Mar 27 2020 at 10:05)</a>:</h4>
<p>This is not related to foreign unwinding. We mark <code>extern "C"</code> functions as <code>nounwind</code>, so it is unsound if we let a panic out of them.</p>



<a name="191996381"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/moving%20toward%20an%20RFC/near/191996381" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/moving.20toward.20an.20RFC.html#191996381">(Mar 27 2020 at 10:06)</a>:</h4>
<p>To clarify: this is talking about <code>extern "C"</code> functions written in Rust.</p>



<a name="191997018"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/moving%20toward%20an%20RFC/near/191997018" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/moving.20toward.20an.20RFC.html#191997018">(Mar 27 2020 at 10:12)</a>:</h4>
<p>Ok, I thought this was about <code>extern "C" { fn foo(); }</code>.</p>



<a name="192098031"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/moving%20toward%20an%20RFC/near/192098031" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/moving.20toward.20an.20RFC.html#192098031">(Mar 28 2020 at 01:18)</a>:</h4>
<p>I guess the question is -- who wants to start writing the RFC :) <span class="user-mention" data-user-id="120076">@BatmanAoD (Kyle Strand)</span> are you interested?</p>



<a name="192143760"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/moving%20toward%20an%20RFC/near/192143760" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/moving.20toward.20an.20RFC.html#192143760">(Mar 28 2020 at 22:06)</a>:</h4>
<p>I can take a shot at that this week.</p>



<a name="192699882"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/moving%20toward%20an%20RFC/near/192699882" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/moving.20toward.20an.20RFC.html#192699882">(Apr 02 2020 at 17:30)</a>:</h4>
<p><span class="user-mention" data-user-id="120076">@BatmanAoD (Kyle Strand)</span> any update?</p>



<a name="192699956"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/moving%20toward%20an%20RFC/near/192699956" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/moving.20toward.20an.20RFC.html#192699956">(Apr 02 2020 at 17:30)</a>:</h4>
<p>I'm probably not able to attend a meeting today</p>



<a name="192699965"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/moving%20toward%20an%20RFC/near/192699965" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/moving.20toward.20an.20RFC.html#192699965">(Apr 02 2020 at 17:30)</a>:</h4>
<p>But I think we're at the "write RFC stage" anyhow</p>



<a name="192700228"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/moving%20toward%20an%20RFC/near/192700228" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/moving.20toward.20an.20RFC.html#192700228">(Apr 02 2020 at 17:32)</a>:</h4>
<p>I've started but haven't gotten very far.</p>



<a name="192700382"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/moving%20toward%20an%20RFC/near/192700382" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/moving.20toward.20an.20RFC.html#192700382">(Apr 02 2020 at 17:34)</a>:</h4>
<p>I copied various notes into the repo, too, with links to the originals. I made a separate PR, but I can just merge it without review if you don't mind.</p>



<a name="192706910"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/moving%20toward%20an%20RFC/near/192706910" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/moving.20toward.20an.20RFC.html#192706910">(Apr 02 2020 at 18:26)</a>:</h4>
<blockquote>
<p>clarifies that all unwinding across a C ABI is UB except the case of:
* forced unwind where no destructors are on stack</p>
</blockquote>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> I don't think we sufficiently discussed forced unwind (option 1. vs. 2); there seemed to be cases where this could cause <code>-C panic=unwind</code> &lt;=&gt; <code>-C panic=abort</code> to generate UB whereas I got the impression that wasn't the case earlier in the meeting</p>



<a name="192707701"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/moving%20toward%20an%20RFC/near/192707701" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/moving.20toward.20an.20RFC.html#192707701">(Apr 02 2020 at 18:33)</a>:</h4>
<p>I thought <span class="user-mention" data-user-id="143274">@Amanieu</span> had reassured me on that issue (where Proposal 1 avoids UB that's present in Proposal 2) during our meeting on 2 March, but I don't see that recorded in our notes, unfortunately. I thought I remembered a comment to the effect that it's essentially a wash for some reason...</p>



<a name="192707816"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/moving%20toward%20an%20RFC/near/192707816" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/moving.20toward.20an.20RFC.html#192707816">(Apr 02 2020 at 18:34)</a>:</h4>
<p>T-Lang pre-triage now; I'll try to look later</p>



<a name="192711739"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/moving%20toward%20an%20RFC/near/192711739" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/moving.20toward.20an.20RFC.html#192711739">(Apr 02 2020 at 19:10)</a>:</h4>
<p><span class="user-mention" data-user-id="143274">@Amanieu</span> do you think the initial RFC, introducing <code>"C unwind"</code>, should specify what happens when a frame with <code>catch_unwind</code> is unwound by a foreign exception? Or should that be UB for now?</p>



<a name="192711897"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/moving%20toward%20an%20RFC/near/192711897" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/moving.20toward.20an.20RFC.html#192711897">(Apr 02 2020 at 19:11)</a>:</h4>
<p>I personally feel that we should just specify it, but the lang team seems to be tending towards making it UB for now until a proper use case for it comes up.</p>



<a name="192712264"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/moving%20toward%20an%20RFC/near/192712264" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/moving.20toward.20an.20RFC.html#192712264">(Apr 02 2020 at 19:14)</a>:</h4>
<p>Is there any reason not to specify it as <code>abort</code> for now?</p>



<a name="192712310"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/moving%20toward%20an%20RFC/near/192712310" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/moving.20toward.20an.20RFC.html#192712310">(Apr 02 2020 at 19:14)</a>:</h4>
<p>I guess changing that would be _technically_ breaking...and I think that was mentioned in the PR discussion...</p>



<a name="192712604"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/moving%20toward%20an%20RFC/near/192712604" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/moving.20toward.20an.20RFC.html#192712604">(Apr 02 2020 at 19:17)</a>:</h4>
<p>We only check the type of the exception in <code>catch_unwind</code>, so we can't guarantee that we will always abort.</p>



<a name="192713383"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/moving%20toward%20an%20RFC/near/192713383" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/moving.20toward.20an.20RFC.html#192713383">(Apr 02 2020 at 19:23)</a>:</h4>
<p>I'm not sure I understand - isn't that sufficient to guarantee that foreign exceptions will abort in any case where they're guaranteed to reach the <code>catch_unwind</code> in the first place?</p>



<a name="192717993"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/moving%20toward%20an%20RFC/near/192717993" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/moving.20toward.20an.20RFC.html#192717993">(Apr 02 2020 at 20:00)</a>:</h4>
<p>Not if you have C++ calling Rust which calls C++ again, all without a <code>catch_unwind</code>, and the inner C++ throws an exception.</p>



<a name="192722848"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/moving%20toward%20an%20RFC/near/192722848" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/moving.20toward.20an.20RFC.html#192722848">(Apr 02 2020 at 20:37)</a>:</h4>
<p>Oh, I'm only asking about <code>catch_unwind</code>.</p>



<a name="192723408"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/moving%20toward%20an%20RFC/near/192723408" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/moving.20toward.20an.20RFC.html#192723408">(Apr 02 2020 at 20:42)</a>:</h4>
<p>If you want to review the spec as I've explained it in my draft RFC, here it is: <a href="https://github.com/BatmanAoD/project-ffi-unwind/blob/c-unwind-rfc/rfcs/0000-c-unwind-abi.md" title="https://github.com/BatmanAoD/project-ffi-unwind/blob/c-unwind-rfc/rfcs/0000-c-unwind-abi.md">https://github.com/BatmanAoD/project-ffi-unwind/blob/c-unwind-rfc/rfcs/0000-c-unwind-abi.md</a></p>



<a name="192725909"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/moving%20toward%20an%20RFC/near/192725909" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/moving.20toward.20an.20RFC.html#192725909">(Apr 02 2020 at 21:03)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> I forgot until just now that your above comment says the RFC should leave behavior for foreign exceptions "unspecified." Is there a reason for doing that instead of introducing the specification based on the table in the blog post?</p>



<a name="192728469"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/moving%20toward%20an%20RFC/near/192728469" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/moving.20toward.20an.20RFC.html#192728469">(Apr 02 2020 at 21:23)</a>:</h4>
<p><span class="user-mention silent" data-user-id="120076">BatmanAoD (Kyle Strand)</span> <a href="#narrow/stream/210922-project-ffi-unwind/topic/moving.20toward.20an.20RFC/near/192707701" title="#narrow/stream/210922-project-ffi-unwind/topic/moving.20toward.20an.20RFC/near/192707701">said</a>:</p>
<blockquote>
<p>I thought <span class="user-mention silent" data-user-id="143274">Amanieu</span> had reassured me on that issue (where Proposal 1 avoids UB that's present in Proposal 2) during our meeting on 2 March, but I don't see that recorded in our notes, unfortunately. I thought I remembered a comment to the effect that it's essentially a wash for some reason...</p>
</blockquote>
<p>Oh, I think I remember the reason: in the case of a forced unwind, having destructors in scope is almost certainly UB anyway. For instance, with <code>longjmp</code>, that is definitely true in the general case.</p>



<a name="192754446"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/moving%20toward%20an%20RFC/near/192754446" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/moving.20toward.20an.20RFC.html#192754446">(Apr 03 2020 at 03:30)</a>:</h4>
<p>Okay, I've got a rough draft of an RFC. Thanks to Amanieu for reviewing it already!</p>



<a name="192833113"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/moving%20toward%20an%20RFC/near/192833113" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/moving.20toward.20an.20RFC.html#192833113">(Apr 03 2020 at 16:51)</a>:</h4>
<p><span class="user-mention" data-user-id="143274">@Amanieu</span> <span class="user-mention" data-user-id="116009">@nikomatsakis</span>  Why do we need to leave the behavior of foreign exceptions entering through <code>extern "C" { fn entrypoint(); }</code> undefined for now? Was this discussed in the lang team meeting on 3/26? All I see in the minutes is:</p>
<blockquote>
<ul>
<li>Potentially exclude the behavior of foreign exceptions — they can remain UB<ul>
<li>or we can try to come up with an answer</li>
</ul>
</li>
</ul>
</blockquote>



<a name="192833291"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/moving%20toward%20an%20RFC/near/192833291" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/moving.20toward.20an.20RFC.html#192833291">(Apr 03 2020 at 16:53)</a>:</h4>
<p>Because nobody has proposed a use case for it.</p>



<a name="192833468"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/moving%20toward%20an%20RFC/near/192833468" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/moving.20toward.20an.20RFC.html#192833468">(Apr 03 2020 at 16:54)</a>:</h4>
<p>So far the only people asking about FFI unwinding are the ones who want to throw Rust panics over foreign code.</p>



<a name="192833677"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/moving%20toward%20an%20RFC/near/192833677" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/moving.20toward.20an.20RFC.html#192833677">(Apr 03 2020 at 16:55)</a>:</h4>
<p>Hm.... I am pretty confident that Lucet uses it already</p>



<a name="192834217"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/moving%20toward%20an%20RFC/near/192834217" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/moving.20toward.20an.20RFC.html#192834217">(Apr 03 2020 at 16:59)</a>:</h4>
<p>I think it's fine if we just go ahead and make foreign exceptions well-defined. We'll leave it for the RFC discussion.</p>



<a name="192834296"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/moving%20toward%20an%20RFC/near/192834296" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/moving.20toward.20an.20RFC.html#192834296">(Apr 03 2020 at 16:59)</a>:</h4>
<p>Okay. Should I mark those two comments in your review resolved?</p>



<a name="192834602"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/moving%20toward%20an%20RFC/near/192834602" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/moving.20toward.20an.20RFC.html#192834602">(Apr 03 2020 at 17:01)</a>:</h4>
<p>Sure.</p>



<a name="192835410"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/moving%20toward%20an%20RFC/near/192835410" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/moving.20toward.20an.20RFC.html#192835410">(Apr 03 2020 at 17:07)</a>:</h4>
<p><span aria-label="thumbs up" class="emoji emoji-1f44d" role="img" title="thumbs up">:thumbs_up:</span></p>



<a name="192839208"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/moving%20toward%20an%20RFC/near/192839208" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/moving.20toward.20an.20RFC.html#192839208">(Apr 03 2020 at 17:37)</a>:</h4>
<p><span class="user-mention" data-user-id="143274">@Amanieu</span> Okay, I've changed the sections discussing forced unwind; I _think_ they're correct now. I also called out the fact that the one case where changing <code>panic=unwind</code> to <code>panic=abort</code>introduces UB is actually already UB (even with <code>panic=unwind</code>) most platforms. (In practice, on all but one platform)</p>



<a name="192852025"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/moving%20toward%20an%20RFC/near/192852025" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/moving.20toward.20an.20RFC.html#192852025">(Apr 03 2020 at 19:18)</a>:</h4>
<p>My inclination was to leave that as "not yet specified" -- it seems to me that we don't yet have a satisfactory answer about the interaction with "catch panic", for one thing. I wasn't super happy with "catch but convert to Rust panic", which seems unlikely to be what anyone wants. Abort is "ok" but ungreat, it'd be nice to at least offer an alternative that permits one to rethrow with full fidelity.</p>



<a name="192852061"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/moving%20toward%20an%20RFC/near/192852061" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/moving.20toward.20an.20RFC.html#192852061">(Apr 03 2020 at 19:19)</a>:</h4>
<p>I guess I just don't know that we've even written out the full range of options in a way to discuss</p>



<a name="192852107"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/moving%20toward%20an%20RFC/near/192852107" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/moving.20toward.20an.20RFC.html#192852107">(Apr 03 2020 at 19:19)</a>:</h4>
<p>I'm not <em>entirely</em> convinced we even want foreign exceptions to ever be able to propagate across Rust code, although I also (somewhat contradictorily) think  we want to enable "fluent" C++ interaction, and it seems like that would require us to support foreign exceptions more fully</p>



<a name="192856231"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/moving%20toward%20an%20RFC/near/192856231" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/moving.20toward.20an.20RFC.html#192856231">(Apr 03 2020 at 19:56)</a>:</h4>
<p>I think most use cases probably wouldn't involve <code>catch_panic</code>, just like most uses of <code>panic</code> across C++ frames would use <code>catch_panic</code> rather than C++ <code>catch</code> to stop the <code>panic</code> unwind</p>



<a name="192856379"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/moving%20toward%20an%20RFC/near/192856379" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/moving.20toward.20an.20RFC.html#192856379">(Apr 03 2020 at 19:58)</a>:</h4>
<p>I think one reason I want to support C++ exceptions is just that it seems... arrogant, somehow, to make <code>panic</code>-unwinds the only type of exception that we permit to cross the C++/Rust boundary.</p>



<a name="192856522"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/moving%20toward%20an%20RFC/near/192856522" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/moving.20toward.20an.20RFC.html#192856522">(Apr 03 2020 at 19:58)</a>:</h4>
<p>"Rust's FFI doesn't prevent you from using your other languages' features" is another of those language-values that I have in my head that may not be shared universally.</p>



<a name="192856574"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/moving%20toward%20an%20RFC/near/192856574" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/moving.20toward.20an.20RFC.html#192856574">(Apr 03 2020 at 19:59)</a>:</h4>
<p>Also, UB in this case seems strictly worse than "it just does what you expect."</p>



<a name="193107055"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/moving%20toward%20an%20RFC/near/193107055" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/moving.20toward.20an.20RFC.html#193107055">(Apr 06 2020 at 21:53)</a>:</h4>
<p><span class="user-mention silent" data-user-id="120076">BatmanAoD (Kyle Strand)</span> <a href="#narrow/stream/210922-project-ffi-unwind/topic/moving.20toward.20an.20RFC/near/192856522" title="#narrow/stream/210922-project-ffi-unwind/topic/moving.20toward.20an.20RFC/near/192856522">said</a>:</p>
<blockquote>
<p>"Rust's FFI doesn't prevent you from using your other languages' features" is another of those language-values that I have in my head that may not be shared universally.</p>
</blockquote>
<p>I would call it "Rust gives seamless interop with other systems language, esp. C and C++"</p>



<a name="193107064"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/moving%20toward%20an%20RFC/near/193107064" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/moving.20toward.20an.20RFC.html#193107064">(Apr 06 2020 at 21:53)</a>:</h4>
<p>though we're not there yet :)</p>



<a name="193107077"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/moving%20toward%20an%20RFC/near/193107077" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/moving.20toward.20an.20RFC.html#193107077">(Apr 06 2020 at 21:53)</a>:</h4>
<p>it's true-ish for C, I think it <em>should</em> be true for C++</p>



<a name="193107084"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/moving%20toward%20an%20RFC/near/193107084" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/moving.20toward.20an.20RFC.html#193107084">(Apr 06 2020 at 21:53)</a>:</h4>
<p>otoh, we do require "opt-in" for that interop elsewhere</p>



<a name="193107138"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/moving%20toward%20an%20RFC/near/193107138" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/moving.20toward.20an.20RFC.html#193107138">(Apr 06 2020 at 21:54)</a>:</h4>
<p>but it's definitely an argument for permitting us to interop with C++ exceptions</p>



<a name="193107146"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/moving%20toward%20an%20RFC/near/193107146" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/moving.20toward.20an.20RFC.html#193107146">(Apr 06 2020 at 21:54)</a>:</h4>
<p>(and one I find convincing)</p>



<a name="201073757"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/moving%20toward%20an%20RFC/near/201073757" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/moving.20toward.20an.20RFC.html#201073757">(Jun 16 2020 at 21:03)</a>:</h4>
<p>I can see why, if we were already planning to make foreign exceptions UB, that might make the single-ABI proposal more appealing. But I don't really see why we would want to make foreign exceptions UB in the first place; haven't we discussed that before?</p>



<a name="201080757"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/moving%20toward%20an%20RFC/near/201080757" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/moving.20toward.20an.20RFC.html#201080757">(Jun 16 2020 at 22:15)</a>:</h4>
<p>..we have</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>